<template>
  <div class="home">
    <p style="color: #fba320">
      <i class="el-icon-s-promotion" style="font-size: 24px"></i>
      婚宴场地
    </p>
    <el-card class="page-wrap">
      <el-table :data="listData">
        <el-table-column width="180px" label="图片">
          <template v-slot="{ row }">
            <img :src="aa+row.hotelImg" alt="" class="picture"/>
          </template>
        </el-table-column>
        <el-table-column label="酒店名" prop="hotelName"></el-table-column>
        <el-table-column label="简介" prop="hotelIntroduce" show-overflow-tooltip></el-table-column>
        <el-table-column label="地址" prop="hotelAddress"></el-table-column>
        <el-table-column label="操作" type="primary">
          <template v-slot="{ row }">
            <el-button type="primary" size="small" @click="show(row)"
            >加入购物车
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row type="flex" justify="center" style="margin-top: 30px">
        <el-pagination
          background
          :total="total"
          layout="prev, pager, next"
          :page-size="size"
          @current-change="currentChange">
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import Request from "../api/request";

export default {
  data() {
    return {

      aa: 'data:image/png;base64,',
      listData: [],
      currentPage: '1',
      size: '2',

      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      Request.get(
        "/hotel/u?current=" + this.currentPage +
        "&size=" + this.size)
        .then(res => {
          this.loading = false

          this.listData = res.data.data.records
          // 分页赋值
          this.currentPage = res.data.data.current
          this.size = res.data.data.size
          this.total = res.data.data.total

        })
    },
    currentChange(page) {
      this.currentPage = page
      this.getList();
    },
    show(row) {


      Request.post("car?id=" + row.hotelId + "&type=2").then(res => {


        if (res.data.data) {
          // this.select();
          this.$message({
            duration:1000,
            type: 'success',
            message: '保存成功！'
          })
        } else {
          this.$message({
            duration:1000,
            type: 'info',
            message: ''
          })
        }


      })
    },
  },
};
</script>

<style scoped>
.home {
  width: 60%;
  height: 800px;
  margin: 20px auto;
}

.page-wrap {
  margin-top: 30px;
  /* height: 600px; */
}

.picture {
  width: 180px;
  height: 180px;
}
</style>
